package com.zkadmin.util;

import java.util.Locale;

import javax.servlet.http.HttpServletRequest;

import org.zkoss.util.Locales;
import org.zkoss.web.Attributes;
import org.zkoss.zk.ui.Session;
import org.zkoss.zk.ui.util.RequestInterceptor;


public class ZkLocaleProvider implements RequestInterceptor {

	@Override
	public void request(Session session, Object request, Object response) {
		String localName = CookieUtils.getLocal((HttpServletRequest) request);
		Locale locale = Locales.getLocale(localName);
		((HttpServletRequest) request).getSession().setAttribute(Attributes.PREFERRED_LOCALE, locale);
	}
}
